package com.zszq.ms.bigmodeltest.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zszq.ms.bigmodeltest.entity.AiBigmodelConfig;
import com.zszq.ms.bigmodeltest.enums.DeleteFlagEnum;
import com.zszq.ms.bigmodeltest.mapper.AiBigmodelConfigMapper;
import com.zszq.ms.bigmodeltest.service.AiBigmodelConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ms
 * @since 2025-03-31
 */
@Service
public class AiBigmodelConfigImpl extends ServiceImpl<AiBigmodelConfigMapper, AiBigmodelConfig> implements AiBigmodelConfigService {

    @Override
    public List<AiBigmodelConfig> getAllEnableConfig() {
        LambdaQueryWrapper<AiBigmodelConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(AiBigmodelConfig::getDeleteFlag, DeleteFlagEnum.NO.getCode());
        lambdaQueryWrapper.eq(AiBigmodelConfig::getEnableFlag, DeleteFlagEnum.YES.getCode());
        return baseMapper.selectList(lambdaQueryWrapper);
    }

    @Override
    public AiBigmodelConfig getConfigByCode(String code) {
        LambdaQueryWrapper<AiBigmodelConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(AiBigmodelConfig::getCode, code);
        lambdaQueryWrapper.eq(AiBigmodelConfig::getDeleteFlag, DeleteFlagEnum.NO.getCode());
        lambdaQueryWrapper.eq(AiBigmodelConfig::getEnableFlag, DeleteFlagEnum.YES.getCode());
        return baseMapper.selectOne(lambdaQueryWrapper);
    }

    @Override
    public List<AiBigmodelConfig> getConfigByName(String name) {
        LambdaQueryWrapper<AiBigmodelConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(AiBigmodelConfig::getName, name);
        lambdaQueryWrapper.eq(AiBigmodelConfig::getDeleteFlag, DeleteFlagEnum.NO.getCode());
        lambdaQueryWrapper.eq(AiBigmodelConfig::getEnableFlag, DeleteFlagEnum.YES.getCode());
        return baseMapper.selectList(lambdaQueryWrapper);
    }
}
